<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script src="./jquery/jquery-1.12.4.min.js"></script>
<style>
    * {
        padding: 0;
        margin: 0;
    }

    .box {
        width: 500px;
        height: 500px;
        background-color: pink;
        /*  padding: 10px;
        border: 5px solid red; */
        position: relative;
        left: 100px;
        top: 100px;
    }

    .inner {
        width: 100px;
        height: 100px;
        background-color: yellow;
        position: absolute;
        left: 100px;
        top: 100px;
    }
</style>

<body>
    <div class="box">
        <div class="inner"></div>
    </div>
    <script>
        // console.log($('.box'));
        var $box = $('.box');
        // 获取的是内容区的尺寸
        console.log($box.width(), $box.height());
        // 内容区加padding区域的值
        console.log($box.innerWidth(), $box.innerHeight());
        // 内容区加padding区域加border区域
        console.log($box.outerWidth(), $box.outerHeight());

        /*  offset()是得到盒子距离页面左上角的坐标*/
        console.log($('.box').offset());
        console.log($('.inner').offset());
        // position()获取的是盒子距离父元素左上角的距离
        console.log($('.box').position());
        console.log($('.inner').position());


    </script>
</body>

</html>